<template>
	<div class="detail">
		<div class="content">
			<div class="title">
				{{loadData.name}}
			</div>
			<van-divider />
			<div class="a-title">{{detail.title}}</div>
			<div class="props">
				<span>发起人：{{detail.resource}}</span>
				<span>时间：{{detail.publishtime_text}}</span>
				<span>浏览：{{detail.reading}}次</span>
			</div>
			<div class="text" v-html="detail.postcontent">
				
			</div>
		</div>
		<Comment ref="comment"></Comment>

	</div>
</template>

<script>
	import Comment from "@/components/comment.vue"
	export default {
		name: "Detail",
		components: {
			Comment
		},
		data() {
			return {
				loadData:{},
				detail:{}
			}
		},
		// watch:{
		// 	"loadData":function(){
		// 		this.getData()
		// 	}
		// },
		created() {
			this.loadData = this.$localStorage.get("secondLevel")
			this.getData()
		},
		methods:{
			getData(){
				let detailData = {
					category_id:this.loadData.url,
					site_id:this.$localStorage.get("site_id")
				}
				this.$api.home.firstArticle(detailData).then(res => {
					// 执行某些操作
					if (res.code == 1) {
						if(res.data){
							this.detail = res.data||{}
							if(this.$refs.comment){
								this.$refs.comment.getList(res.data.id)
							}
						}else{
							this.$router.push({
								path:"/classify/"
							})
						}
						
						
					}
				
				})
			}
		}


	}
</script>

<style lang="less">
	.detail {
		.content {
			padding: 1.63rem 0.94rem;
			background: #fff;

			.title {
				font-size: 0.94rem;
				font-family: PingFang SC;
				font-weight: bold;
				color: rgba(38, 38, 38, 1);
			}
			.a-title{
				text-align: center;
				font-size: 0.94rem;
				font-family: PingFang SC;
				font-weight: bold;
				color: rgba(38, 38, 38, 1);
				margin: 1rem auto;
			}

			.props {
				font-size: 0.69rem;
				font-family: PingFang SC;
				font-weight: 500;
				color: rgba(147, 147, 147, 1);
				display: flex;
				justify-content: space-between;
			}
			.text{
				font-size:0.81rem;
				font-family:PingFang SC;
				font-weight:500;
				color:rgba(54,54,54,1);
				line-height:1.25rem;
				margin-top: 1.81rem;
			}
		}

	}
</style>
